/* This is a simple program that prints out the first
 * max fibonacci numbers, each number on a new line.
 * Uses ecrire() to write to the console and gets input using lire()
 */

#include "fibonacci.h"

void fibonacci(){

  int v1 = 0;
  int v2 = 1;
  char buffer[10];
  int max;
  
  ecrire("Fibonacci\n");
  ecrire("Enter the maximum number of the serie:");
  lire(buffer,10);
  max = atoi(buffer); //0 if buffer does not contain an integer

  ecrire("\n");
  ecrire(itoa(v1,buffer,10));
  ecrire(itoa(v2,buffer,10));
  ecrire("\n");

  while(v1+v2 <= max){
    ecrire(itoa(v1+v2,buffer,10));
    ecrire("\n");
    v2 += v1; //store the new fibonacci number
    v1 = v2 - v1;
  }
  ecrire("done.\n");

  int p[4] = {1,2,3, 4};
  fourchette(4,"count",p);
  fourchette(1,"increment",NULL);
  quitter(0);

}
